package com.liaowei.article.controller;

import com.liaowei.article.service.ArticleUserService;
import com.liaowei.common.BaseResponse;
import com.liaowei.common.ResultUtils;
import com.liaowei.model.param.ArticleCommentStatusParam;
import com.liaowei.model.param.ArticleUserParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("users")
@RequiredArgsConstructor
public class ArticleUserController {

    private final ArticleUserService articleUserService;

    // 点赞或收藏文章
    @PostMapping("starOrColl")
    public BaseResponse<String> starOrCollArticle(@RequestBody ArticleUserParam articleUserParam) {
        return ResultUtils.success(articleUserService.starOrCollArticle(articleUserParam));
    }

    // 根据id修改评论状态
    @PutMapping("comment/status")
    public BaseResponse<String> commentStatus(@RequestBody @Validated ArticleCommentStatusParam commentStatusParam) {
        return ResultUtils.success(articleUserService.updateCommentStatus(commentStatusParam));
    }

    // 保存articleUser
    @PostMapping
    public BaseResponse<String> saveArticleUser(@RequestBody @Validated ArticleUserParam articleUserParam) {
        return ResultUtils.success(articleUserService.saveArticleUser(articleUserParam));
    }
}
